/*
 * @Author: your name
 * @Date: 2020-11-19 20:47:41
 * @LastEditTime: 2020-12-06 11:28:02
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \wechat-server\routes\weibo\realtimeList.js
 */
import Router from "koa-router";
import axios from "axios";

const router = Router();

router.get("/weibo/hotComments/:id/:mid", async (ctx, next) => {
  let id = ctx.params["id"];
  let mid = ctx.params["mid"];
  let headers = {
    "User-Agent":
      "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36",
    "Accept-Language": "en-US,en;q=0.5",
    "WeiboData-Type": "application/x-www-form-urlencoded",
    Connection: "Keep-Alive",
    // cookie: cookies.toString(),
  };
  let data = await axios
    .get("https://m.weibo.cn/comments/hotflow?", {
      headers: headers,
      params: {
        id: id,
        mid: mid,
        max_id_type: "0",
      },
    })
    .then((res) => res.data)
    .catch((err) => {
      console.log("获取评论失败：", err);
    });
  ctx.body = data;
});

export default router;
